<?php

use Illuminate\Database\Seeder;

use App\Order;

class OrdersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        for ($i = 0; $i < 100; $i++) {
            $orders = factory(Order::class)->times(20000)->make();
            $sql = sprintf("insert into orders (uid, amount, created_at, updated_at) values ");
            $values = [];
            foreach ($orders as $order) {
                $values[] = sprintf("('%s', '%s', '%s', '%s')", $order->uid, $order->amount, $order->created_at->format('Y-m-d H:i:s'), $order->updated_at->format('Y-m-d H:i:s'));
            }
            $sql .= implode(',', $values);
            $result = \DB::statement($sql);
            dump($i, $result);
        }
    }
}
